package com.qingcloud.df.executor.log.impl;

import com.qingcloud.df.executor.pojo.JobInstanceLog;
import com.qingcloud.df.executor.log.IComponentLogger;

import java.util.Objects;

/**
 * 组件JDBC类型日志实现类型
 *
 * @author wangjinnan
 */
public class ComponentJdbcLogger implements IComponentLogger {

    /**
     * 单例对象
     */
    private static volatile ComponentJdbcLogger instance = null;

    private ComponentJdbcLogger() {

    }

    /**
     * 获取单例对象
     */
    public static ComponentJdbcLogger getInstance() {
        if (Objects.isNull(instance)) {
            synchronized (ComponentJdbcLogger.class) {
                if (Objects.isNull(instance)) {
                    instance = new ComponentJdbcLogger();
                }
            }
        }
        return instance;
    }

    /**
     * 追加utf8日志内容
     *
     * @param instanceId 组件实例ID
     * @param content    日志内容，utf8编码
     * @return 追加是否成功
     */
    @Override
    public Boolean appendUtf8Log(Integer jobId, Integer instanceId, String softwareName, String content, String env) {
        throw new UnsupportedOperationException("暂时未实现使用JDBC方式保存组件运行日志");
    }

    @Override
    public JobInstanceLog preLog(Integer jobId, Integer instanceId, String softwareName, Long preStart, Long afterStart, Integer size, String day, String env) {
        throw new UnsupportedOperationException("暂时未实现使用JDBC方式保存组件运行日志");
    }

    @Override
    public JobInstanceLog afterLog(Integer jobId, Integer instanceId, String softwareName, Long preStart, Long afterStart, Integer size, String day, String env) {
        throw new UnsupportedOperationException("暂时未实现使用JDBC方式保存组件运行日志");
    }

    @Override
    public JobInstanceLog readNewestLog(Integer jobId, Integer instanceId, String softwareName, Integer size, String day, String env) {
        throw new UnsupportedOperationException("暂时未实现使用JDBC方式保存组件运行日志");
    }

}
